//http://www.glitech.com/index.html#/en
var scriptAppend = '<script  src="/js/swiper/swiper-4.2.2.min.js"></script>';
var isTest = window.location.host == "bluelotos.gitee.io" ? true : false;
if(isTest){
    scriptAppend = '<script  src="/glitech/js/swiper/swiper-4.2.2.min.js"></script>';
}
$("head").append(scriptAppend);

//轮播图区域，鼠标移入时显示左右箭头
$("div.swiper-container").mouseenter(function () {
    $(this).find(".el-carousel__arrow").show();
});
$("div.swiper-container").mouseleave(function () {
    $(this).find(".el-carousel__arrow").hide();
});

//初始化轮播图
window.initSwiperShow = function (ele) {
    var mySwiper = new Swiper(ele, {
        navigation: {
            nextEl: '.el-carousel__arrow--right',
            prevEl: '.el-carousel__arrow--left'
        },
        loop: true,
        autoplay: {
            delay: 3000,
            stopOnLastSlide: false,
            disableOnInteraction: true,
        },
        pagination: {
            el: '.swiper-pagination',
        },
    });
}

//中英文切换和顶部四个模块跳转方法
window.changePageModule = function (m, lang) {
    var isTest = window.location.host == "bluelotos.gitee.io" ? true : false;
    //码云网络环境
    if (isTest) {
        switch (m) {
            case 1:
                if (lang == "cn") {
                    window.location = "/glitech/zh-cn/index.html";
                } else {
                    window.location = "/glitech/index.html";
                }

                break;
            case 2:
                if (lang == "cn") {
                    window.location = "/glitech/zh-cn/product.html";
                } else {
                    window.location = "/glitech/en/product.html";
                }

                break;
            case 3:
                if (lang == "cn") {
                    window.location = "/glitech/zh-cn/about.html";
                } else {
                    window.location = "/glitech/en/about.html";
                }

                break;
            case 4:
                if (lang == "cn") {
                    window.location = "/glitech/zh-cn/support.html";
                } else {
                    window.location = "/glitech/en/support.html";
                }

                break;

            default:
                break;
        }
        return false;
    }

    //本地或线上环境
    switch (m) {
        case 1:
            if (lang == "cn") {
                window.location = "/zh-cn/index.html";
            } else {
                window.location = "/index.html";
            }

            break;
        case 2:
            if (lang == "cn") {
                window.location = "/zh-cn/product.html";
            } else {
                window.location = "/en/product.html";
            }

            break;
        case 3:
            if (lang == "cn") {
                window.location = "/zh-cn/about.html";
            } else {
                window.location = "/en/about.html";
            }

            break;
        case 4:
            if (lang == "cn") {
                window.location = "/zh-cn/support.html";
            } else {
                window.location = "/en/support.html";
            }

            break;

        default:
            break;
    }
}
function mainPageAnimate(){
    var $index = 0;
    $('.mask-list>.mask-item').hover(
        function () {
            $('.mask-list').addClass('active');
            $index = $(this).index();
            $(this)
                .addClass('active')
                .siblings('.mask-item')
                .removeClass('active');
            $('.cover-list-item')
                .eq($index)
                .css({ width: '100%', opacity: 0 }, 500)
                .siblings('.cover-list-item')
                .css({ width: 0, opacity: 0 }, 500);
            $('.video-item')
                .eq($index)
                .css({ opacity: 1 })
                .siblings('.video-item')
                .css({ opacity: 0 });
            document.getElementsByTagName('video')[$index].load();
            document.getElementsByTagName('video')[$index].play();
        },
        function () {
            $('.cover-list-item').css({ width: '33.333%', opacity: 1 });
            $('.video-item').css({ opacity: 1 });
            $('.mask-list,.mask-item').removeClass('active');
        }
    )
}
//顶部的四个模块切换
$("#app").on("click", "#top-nav-container .top-nav", function () {
    $("#top-nav-container .top-nav").removeClass("isActive");
    $(this).addClass("isActive");
    var m = $(this).data("m");
    var lang = $("#change-language").data("lang");
    changePageModule(m, lang)
})
//中英文切换
$("#app").on("click", "#change-language", function () {
    var m = $("#top-nav-container .top-nav.isActive").data("m");
    var lang = $("#change-language").data("lang") == "cn" ? "en" : "cn";
    changePageModule(m, lang)
})






